# Contributor: Marc Vertes <mvertes@free.fr>
# Maintainer: Marc Vertes <mvertes@free.fr>
pkgname=seamonkey
pkgver=2.49.5
pkgrel=4
pkgdesc="all-in-one internet application suite"
url="https://www.seamonkey-project.org/"
arch="x86_64 x86"
license="GPL-3.0-only AND LGPL-2.1-only AND LGPL-3.0-only AND MPL-2.0"
makedepends="unzip zip gtk+3.0-dev gtk+2.0-dev yasm alsa-lib-dev libxt-dev linux-headers
	hunspell-dev nspr-dev nss-dev jpeg-dev bzip2-dev zlib-dev libpng-dev
	libevent-dev libvpx-dev sqlite-dev libffi-dev pixman-dev python2-dev
	icu-dev m4 libxcomposite-dev autoconf2.13 nss-static
	!firefox
	"
source="https://archive.mozilla.org/pub/mozilla.org/seamonkey/releases/$pkgver/source/seamonkey-$pkgver.source.tar.xz
	mozconfig
	fix-aouth.patch
	fix-crmf.patch
	fix-hunspell.patch
	fix-i686-musl.patch
	fix-libevent.patch
	fix-libgen.patch
	fix-linux-syscall.patch
	fix-mallinfo.patch
	fix-platform-linux.patch
	fix-siginfo_t.patch
	fix-stabs.patch
	fix-sysctl.patch
	fix-system-headers.patch
	firefox-gcc-6.0.patch
	avoid-getcontext-musl.patch
	discard-x86-precision-musl.patch
	"
options="!check"

build() {
	cp ../../mozconfig .mozconfig
	export MOZ_MAKE_FLAGS="$MAKEFLAGS"
	export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/seamonkey-$pkgver"
	export SHELL="/bin/ash"
	unset MAKEFLAGS CPPFLAGS

	# Disable some optimizations in gcc6 (rhbz#1328045)
	CFLAGS="$CFLAGS -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2 -D_FILE_OFFSET_BITS=64"
	CXXFLAGS="$CXXFLAGS -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2 -D_FILE_OFFSET_BITS=64"

	make -f client.mk build
}

package() {
	make -f client.mk DESTDIR="$pkgdir" INSTALL_SDK= install

	rm -rf "$pkgdir/usr/lib/seamonkey-$pkgver/dictionaries" \
		"$pkgdir/usr/lib/seamonkey-$pkgver/hypenation"
	ln -s /usr/share/hunspell \
		"$pkgdir/usr/lib/seamonkey-$pkgver/dictionaries"
	ln -s /usr/share/hyphen \
		"$pkgdir/usr/lib/seamonkey-$pkgver/hyphenation"
	install -Dm644 suite/branding/nightly/icons/gtk/seamonkey.png \
		"$pkgdir/usr/share/pixmaps/seamonkey.png"
	install -Dm644 mozilla/toolkit/mozapps/installer/linux/rpm/mozilla.desktop \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	sed -i 's/@MOZ_APP_DISPLAYNAME@/SeaMonkey internet suite/' \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	sed -i 's/@MOZ_APP_NAME@/seamonkey/' \
		"$pkgdir/usr/share/applications/seamonkey.desktop"
	rm -f "$pkgdir/usr/lib/pkgconfig/seamonkey-nss.pc"
	rm -f "$pkgdir/usr/lib/pkgconfig/seamonkey-nspr.pc"
}

sha512sums="31309def1ad4276f13ecb343e936c7cade4b6850db88d9d84700f86bff7024b2b217b9e50fc3756b1d1beea483ceaa2a5a3afd053da00f6ac06e3795e9116789  seamonkey-2.49.5.source.tar.xz
88bd5980cee447ef6fe8c837b60e2ee15dd2737ba3905a443085317da91e4942654e3a2b56b9b67a25844883c9690f504a664255030951bfac6c227cabb79a11  mozconfig
c3b3b5a32f8672a42c051c03c31761414ce52c4a32258f1c7417af7de891e4b5f620ef2762034a18f84e5c7235559d920963aff0f28c2c1f4ae697a38d49b89c  fix-aouth.patch
e0f8e06ac71e5b4defdee80915793848e618174a9ba538477247a479bc7341ae312c66945b7b206f5f22c576091555a67223d7189e95f7b08a20f26d5e9bd2fc  fix-crmf.patch
ea58a2cf58e7d1d99a2346a6977fcb2acff8052e304f9f0d66e24241d77fe352610537c4d2a886b9085b970368dbe46e5011acc210bebcdf22a88a4b5be960b1  fix-hunspell.patch
ac6ad28654723f8ee56f6ddcf2dc2800ee217cd4946cc6b543242881aeaf3edc9f66664205fb6939cec9ce4a2cb2ead4758c0ce021858b672b297ba9295fa392  fix-i686-musl.patch
c2a83214cadc827dd6d37c635ea92ff0779849e55e524b831f1a82ca09dc985770212a81377c2519c3470d752e922fa360d6e49fdfc1f6e9ee581f30ad1885f1  fix-libevent.patch
f148a9212b9d1bf62ce99e3ea69233fcdd74ffb0948ab53d17ec417539b4f9533409b2e9c487e3789b76cdfca92da074b9ea0f82452f56f72eced9cfbcd078f1  fix-libgen.patch
fe377b6c0acbbb569f363cde2de8c640837237120bcbc3099cb9d9691f5b576cd76c531b0019e45385f696d7be60bb97141e39f2de742cb6d1a138fbcf217cc5  fix-linux-syscall.patch
fd6b68082843a17a97a09953f24f74e72090acbcd245e8564ffe41ed5cb0a7afbf3dfc653a6e33a5f0bb0218ec11430f92acedc0c98a32c17dd2a053c3eef855  fix-mallinfo.patch
25bb4f99a2d831a8604444a1071ca946c14b9fe416929660ce6f9d196b3cecbd84b8706a8a16f2653db0d722a8f033fac9dc2f295bf5b59e7f39024d89221d01  fix-platform-linux.patch
285e9330810b0f57ebba3d15cb371543840a7c6b8a2656d6d6b3ad7e8d2ec840b34bcb75b92c3747b5a1b42625fbde3a5d1bbec7052ce47fe5455e5076ec6268  fix-siginfo_t.patch
4a7fae85299969618d729021ed79ab312650419dd849800c4e93c2b78a063a91f4003e2ee66c74abefa28b881376cf78f52e99e5ae3c08b85ba11eeae73a5034  fix-stabs.patch
43e800bdb15a11c21f71d0552ae2e92ad97574eb324f7be75cc92ed98332201386f9c9846d3e5f27b4e71452ffac71ab5b82ffdc2091d6c4830b9cb792bbdde4  fix-sysctl.patch
d65900a74901d0455266342e4efbb655d67c62b52e69f482c33c3da3e24af900a3186f1398b88cccd9e822395480cd4ec4ce0d6053978003911457cacc36f767  fix-system-headers.patch
664983718ba4ed2588850f499cc7da94f2b35d384b6655b1e5ec118e45e8cbd108aa2b9e04cc4b902f4ddba2e1be2cffb056643e053761bfc6da92c942f30305  firefox-gcc-6.0.patch
c67d6df7ee04539abe126493c2fb61b1377b0cc6d84f660b36ed74e940b575a81830c9d50ce52a70df1ddd1747439b4cef31cbb1642545c176da1d82361fa7da  avoid-getcontext-musl.patch
e6023a4c01204f716849045f1ad3958dd2c0a62540f2b738beda7945ebbe836aabe9017463452ef6cad4df1a53642f2e7a5750870bdfd67d8a4ef6fdae775166  discard-x86-precision-musl.patch"
